﻿' NOTE: If you change the class name "Service1" here, you must also update the reference to "Service1" in Web.config and in the associated .svc file.
Imports PizzaManiaDAL

Public Class Service1
    Implements IService1


    Public Sub New()
    End Sub

    Public Function GetAllCustomers() As System.Collections.Generic.IEnumerable(Of PizzaManiaDAL.Customer) Implements IService1.GetAllCustomers
        Return CustomerDataManager.GetAllCustomers()
    End Function

    Public Function SaveCustomer(ByRef cust As PizzaManiaDAL.Customer, ByVal isDelete As Boolean) As Boolean Implements IService1.SaveCustomer
        Try
            Return CustomerDataManager.SaveCustomer(cust, isDelete)
        Catch ex As ValidationException
            Return False
        End Try
    End Function

    Public Function GetOpenOrdersByCustomerID(ByVal customerID As Integer) As System.Collections.Generic.IEnumerable(Of PizzaManiaDAL.Order) Implements IService1.GetOpenOrdersByCustomerID
        Return CustomerDataManager.GetOpenOrdersByCustomerID(customerID)
    End Function

    Public Function SaveCustomers(ByRef updated As PizzaManiaDAL.CustomerList, ByVal deleted As PizzaManiaDAL.CustomerList) As Boolean Implements IService1.SaveCustomers
        Try
            Return CustomerDataManager.SaveCustomers(updated, deleted)
        Catch ex As ValidationException
            Return False
        End Try
    End Function

    Public Function GetCustomerByPhoneNumber(ByVal phone As String) As PizzaManiaDAL.Customer Implements IService1.GetCustomerByPhoneNumber
        Return CustomerDataManager.GetCustomerByPhoneNumber(phone)
    End Function
End Class
